'use strict'
import { QueryInterface, DataTypes } from 'sequelize'
import { generateTradeNo } from '../../utils/tools'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkInsert(
      'Orders',
      [
        {
          outTradeNo: generateTradeNo(),
          userId: 4,
          roleId: 2,
          subject: '库存管理员',
          totalAmount: 0.11,
          paymentMethod: 'alipay',
          status: 0,
          durationMonths: 2,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: generateTradeNo(),
          tradeNo: 'abc123',
          userId: 4,
          roleId: 3,
          subject: '产品管理员',
          totalAmount: 0.21,
          paymentMethod: 'alipay',
          status: 1,
          durationMonths: 3,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: generateTradeNo(),
          userId: 3,
          roleId: 4,
          subject: '运营管理员',
          totalAmount: 0.31,
          paymentMethod: 'alipay',
          status: 2,
          durationMonths: 4,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: generateTradeNo(),
          userId: 3,
          roleId: 2,
          subject: '库存管理员',
          totalAmount: 0.11,
          paymentMethod: 'alipay',
          status: 0,
          durationMonths: 2,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: generateTradeNo(),
          userId: 3,
          roleId: 3,
          subject: '产品管理员',
          totalAmount: 0.21,
          paymentMethod: 'alipay',
          status: 0,
          durationMonths: 3,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
      ],
      {},
    )
  },

  async down(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkDelete('Orders', [], {})
  },
}
